<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<jsp:useBean id="command"  class="com.sanerzone.smscenter.biz.entity.SmsGateway" scope="request" ></jsp:useBean>
<html>
<head>
	<title>指定通道提交</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#btnMenu").remove();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		
		//重新提交
		function reSubmit(){
			var id = $("#ids").val();
			var offerCode = $("#gwCode").val();
			var groupId=$("#groupId").val();
			if((offerCode == null || offerCode =='')&&(groupId == null || groupId == '')){
				alertx("请在通道或者网管组中至少选择一组重发");
				return;
			}
			top.$.jBox.confirm("确认要指定该通道吗？若同时指定组和通道,优先下发组。","系统提示",function(v,h,f){
				if(v=="ok"){
					$.ajax({
						  url: '${ctx}/sms/smsSend/setWaitSended?id='+id+'&gwCode='+offerCode+"&groupId="+groupId,
						  success: function(data){
							  alert(data);
							  window.opener.page();
							  window.close();
						  },
						  error : function(){
							alert("指定该通道失败");
						  },
						  dataType: "text"
						});
					
				}
			},{buttonsFocus:1});
			top.$('.jbox-body .jbox-icon').css('top','55px');
		}
	</script>
</head>
<body>
	<br/>
	<br/>
	<form:form id="inputForm"  action="${ctx}/sms/smsSend/setWaitSended" method="post" class="form-horizontal">
		<input type="hidden" name="ids" value="${smsSend.id}" id="ids">

		<sys:message content="${message}"/>
		<div class="control-group">
			<label class="control-label">重选通道：</label>
			<div class="controls">
				<form:select path="gwCode" class="input-xlarge required" id="gwCode">
					<form:option value="" label="--请选择--"/>
					<form:options items="${fns:getGatewayList()}" itemLabel="gwCode" itemValue="gwCode" htmlEscape="false"/>
				</form:select>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">重选网关分组：</label>
			<div class="controls">
				<form:select path="gwCode" class="input-xlarge required" id="groupId">
					<form:option value="" label="--请选择--"/>
					<form:options items="${fns:getGatewayGroupList()}" itemLabel="name" itemValue="id" htmlEscape="false"/>
				</form:select>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>


		<div class="form-actions">
			<input id="btnSubmit" class="btn btn-primary" type="button" value="保 存" onclick="javascript:reSubmit();"/>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>